<template>
  <div class="mask">
    <div class="service">
      <div class="header">
        <p class="title">当前可服务区域</p>
        <p class="tips">更多区域正在开发中，敬请等待</p>
      </div>

      <div class="area-box" v-for="item in address" :key="item.id">
        <p class="area-name">{{item.city}}</p>
        <div class="area-item">
          <span v-for="area in item.area" :key="area.id">{{area.name}}</span>
        </div>
        <p class="area-tips">（仅提供：城镇区内配送）</p>
      </div>

      <div class="service-tips">
        <p>提示：请确认您的地址范围内有相应的服务站点，水票购买之后不支持退款</p>
      </div>

      <div class="close">
        <img :src="Close" alt @click="handleClose">
      </div>
    </div>
  </div>
</template>

<script>
import api from "../../api";
import Close from "../../assets/common/close.png";
export default {
  props: ["type"],
  data() {
    return {
      address: [],
      Close
    };
  },
  methods: {
    getCanServeArea() {
      api.address.getCanServeArea(res => {
        console.log(res);
        this.address = res;
      });
    },
    handleClose() {
      if (this.type == 'homepage') {
        this.$store.commit('setShowArea');
        this.$emit('closeArea')
      } else {
        this.$emit('closeArea')
      }
    }
  },
  mounted() {
    setTimeout(() => {
      this.getCanServeArea();
    }, 100);
  }
};
</script>

<style lang="less" scoped>
.mask {
  width: 100vw;
  height: 100vh;
  position: fixed;
  z-index: 999;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  .service {
    position: relative;
    width: 90vw;
    background: #fff;
    max-height: 135vw;
    overflow-y: scroll;
    .close {
      position: fixed;
      left: 44vw;
      bottom: 25vw;
      img {
        widows: 1vw;
        height: 10vw;
      }
    }
    .header {
      text-align: center;
      padding-top: 4vw;
      border-bottom: 1px solid #e5e5e5;
      .title {
        font-size: 4.2vw;
        padding-bottom: 2vw;
      }
      .tips {
        font-size: 3vw;
        color: rgb(255, 94, 85);
        padding-bottom: 3vw;
      }
    }
    .area-box {
      padding: 4vw 3vw;
      border-bottom: 1px solid #e5e5e5;
      .area-name {
        font-size: 4vw;
        margin-bottom: 3vw;
      }
      .area-item {
        margin-bottom: 3vw;
        span {
          display: inline-block;
          padding: 2vw 0;
          width: 25vw;
          font-size: 3.2vw;
          text-align: center;
          border: 1px solid #e5e5e5;
          border-radius: 20px;
          margin-right: 2.3vw;
          margin-bottom: 3vw;
        }
      }
      .area-tips {
        font-size: 3vw;
      }
    }
    .service-tips {
      padding: 6vw 3vw;
      font-size: 3.5vw;
      text-align: center;
    }
  }
}
</style>